import 'dart:io';

import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:flutter_widgets_pc/resources/kq_theme_colors.dart';
import 'package:flutter_widgets_pc/theme/configs/common/kq_common_theme_config.dart';
import 'package:flutter_widgets_pc/theme/configs/dialog/kq_dialog_theme_config.dart';
import 'package:flutter_widgets_pc/theme/configs/form/kq_form_theme_config.dart';
import 'package:flutter_widgets_pc/theme/configs/kq_theme_config.dart';
import 'package:flutter_widgets_pc/theme/kq_theme_manager.dart';
import 'package:flutter_widgets_pc_example/resources/theme_colors.dart';

import '../config/global.dart';

class KqStyleUtil {
  /// 初始化主题
  static themeData() {
    /// 初始化Bruno主题
    BrnInitializer.register(
      allThemeConfig: BrnAllThemeConfig(
          appBarConfig: BrnAppBarConfig(titleMaxLength: 15),
          //主题色
          commonConfig: BrnCommonConfig(brandPrimary: KqThemeColors.bgBlue),
          //对话框主题配置
          dialogConfig: BrnDialogConfig(
              contentTextStyle:
                  BrnTextStyle(fontSize: 16, color: KqThemeColors.text333),
              mainActionTextStyle: BrnTextStyle(
                  fontSize: 16, color: KqThemeColors.textLightBlue),
              assistActionsTextStyle:
                  BrnTextStyle(fontSize: 16, color: KqThemeColors.text999)),
          //表单全局样式修改
          formItemConfig: BrnFormItemConfig(
              formPadding: EdgeInsets.fromLTRB(0, 12, 16, 12),
              titlePaddingSm: EdgeInsets.only(left: 16 - 10, right: 8),
              titlePaddingLg: EdgeInsets.only(left: 16, right: 8),
              subTitlePadding: EdgeInsets.only(left: 16, top: 6),
              errorPadding: EdgeInsets.only(left: 16),
              titleTextStyle: BrnTextStyle(fontSize: 14),
              hintTextStyle: BrnTextStyle(fontSize: 14),
              subTitleTextStyle: BrnTextStyle(fontSize: 12),
              contentTextStyle: BrnTextStyle(fontSize: 14),
              optionTextStyle: BrnTextStyle(fontSize: 14),
              disableTextStyle:
                  BrnTextStyle(fontSize: 14, color: KqThemeColors.text333),
              optionSelectedTextStyle:
                  BrnTextStyle(fontSize: 14, color: KqThemeColors.text333))),
    );

    /// 初始化KQ主题-黄色
    KqThemeManager.instance.register(
        KqThemeConfig(
            commonThemeConfig: KqCommonThemeConfig(
                mainColor: KqThemeColors.textYellow,
                mainLightColor: KqThemeColors.textRed,
                titleBarHeight: Platform.isWindows ? 32 : 28,
                lineColor: KqThemeColors.lineColor),
            dialogConfig:
                KqDialogThemeConfig(mainBtnColor: KqThemeColors.textRed),
            formConfig: KqFormThemeConfig(
                mustInputFontSize: 14,
                titleFontSize: 16,
                contentFontSize: 16,
                unitFontSize: 16,
                headerFontSize: 14)),
        configId: Global.themeYellow);

    /// 初始化KQ主题-红色
    KqThemeManager.instance.register(
        KqThemeConfig(
            commonThemeConfig: KqCommonThemeConfig(
                mainColor: KqThemeColors.textRed,
                mainLightColor: KqThemeColors.textYellow,
                titleBarHeight: Platform.isWindows ? 32 : 28,
                lineColor: KqThemeColors.lineColor),
            dialogConfig:
                KqDialogThemeConfig(mainBtnColor: KqThemeColors.textRed),
            formConfig: KqFormThemeConfig(
                mustInputFontSize: 14,
                titleFontSize: 16,
                contentFontSize: 16,
                unitFontSize: 16,
                headerFontSize: 14)),
        configId: Global.themeRed);

    /// 初始化KQ主题-蓝色
    KqThemeManager.instance.register(
        KqThemeConfig(
            commonThemeConfig: KqCommonThemeConfig(
                mainColor: KqThemeColors.bgBlue,
                mainLightColor: KqThemeColors.textLightBlue,
                titleBarHeight: Platform.isWindows ? 32 : 28,
                lineColor: KqThemeColors.lineColor),
            dialogConfig:
                KqDialogThemeConfig(mainBtnColor: KqThemeColors.textLightBlue),
            formConfig: KqFormThemeConfig(
                mustInputFontSize: 14,
                titleFontSize: 16,
                contentFontSize: 16,
                unitFontSize: 16,
                headerFontSize: 14)),
        configId: Global.themeBlue);

    /// 初始化KQ主题-黑色
    KqThemeManager.instance.register(
        KqThemeConfig(
            commonThemeConfig: KqCommonThemeConfig(
                mainColor: KqThemeColors.text333,
                mainLightColor: KqThemeColors.text666,
                titleBarHeight: Platform.isWindows ? 32 : 28,
                lineColor: KqThemeColors.lineColor),
            dialogConfig:
                KqDialogThemeConfig(mainBtnColor: KqThemeColors.textRed),
            formConfig: KqFormThemeConfig(
                mustInputFontSize: 14,
                titleFontSize: 16,
                contentFontSize: 16,
                unitFontSize: 16,
                headerFontSize: 14)),
        configId: Global.themeDark);
  }
}
